#include "sizerestriction.hpp"

#include <QLineEdit>
#include <QIntValidator>
#include <QCalendarWidget>
#include <QMessageBox>
#include <cmath>

SizeRestriction::SizeRestriction(int type):RestrictionLayout(type){
	qlesize=new QLineEdit();
	QIntValidator *qiv=new QIntValidator(0);
	qlesize->setValidator(qiv);
	qcbunit=new QComboBox();
	qcbunit->addItem("B");
	qcbunit->addItem("KB");
	qcbunit->addItem("MB");
	qcbunit->addItem("GB");
	
	this->addWidget(qlname);
	this->addWidget(qlesize);
	this->addWidget(qcbunit);
	this->addWidget(qpbrm);
}

SizeRestriction::~SizeRestriction(){
	delete qcbunit;
	delete qlesize;
}

qint64 SizeRestriction::getSize(){
	if(qlesize->displayText()!="")
		return (qint64)(qlesize->text().toLongLong()*exp(10*qcbunit->currentIndex()*log(2)));
	else
		return -1;
	
}

QLineEdit *SizeRestriction::getLine(){
	return this->qlesize;
}
